<template>
  <div>
    <div class="title">
      <span class="beforetop" v-show="types==='top'">Top</span>
      <span class="beforetitle" v-show="types==='list'"></span>
      {{item.title}}
    </div>
    <span class="author">{{item.author}}</span>
    <span class="date">{{item.date}}</span>
    <div class="words" v-html="item.words"></div>
    <div class="others">
      <div class="icons">
              <span @click="$emit('good')" style="cursor:pointer">
                <span class="iconfont icon-good"></span>
                {{item.good}}
              </span>
        <span style="margin-left:10px;"></span>
        <span @click="$emit('bad')" style="cursor:pointer;display: none">
                <span class="iconfont icon-bad"></span>
                {{item.bad}}
              </span>
        <span style="margin-left:10px;"></span>
        <span class="iconfont icon-code"></span>
        {{item.comment}}
      </div>
      <div class="saw">被浏览{{item.saw}}次</div>
      <input type="text" v-model="commenttext"  class="commentcover">
      <div class="sendcomment" @click="send">评论！</div>
      <div class="org" @click="$emit('go')">查看原文</div>
    </div>
  </div>
</template>

<script>

  export default {
    name: 'Wordcover',
    props:['item','types'],
    data() {
      return {
        commenttext:''
      }
    },
    methods: {
      send() {
        this.$http.post('/api/14ch/sendcomment', {id: this.item.id, comment: this.commenttext}).then((res) => {
          this.commenttext = '';
          this.$emit('update');
        })
      },
    },
    created() {
    },
    mounted() {
    }
  }
</script>

<style scoped>
  .beforetitle {
    display: inline-block;
    position: relative;
    left: 1px;
    top: 2px;
    width: 5px;
    height: 25px;
    background: #e0e0e0;
  }
  .beforetop {
    display: inline-block;
    position: relative;
    left: 1px;
    top: -5px;
    width: 30px;
    height: 25px;
    font-size: 15px;
    padding-left: 2px;
    background: #80cafb;
    color: #fff;
    line-height: 25px;
  }
  .title {
    display: block;
    position: absolute;
    left: 5px;
    top: 4px;
    line-height: 45px;
    width: calc(100% - 10px);
    height: 40px;
    font-size: 26px;
    background: #fff;
    box-shadow: 1px 1px 2px #e9e9e9;
    font-weight: bold;
    text-align: left;
    border-radius: 5px;
  }
  .author {
    position: absolute;
    right: 10px;
    top: 10px;
    font-size: 11px;
    font-weight: 800;
    line-height: 10px;
  }

  .date {
    position: absolute;
    right: 10px;
    top: 25px;
    /*float: right;*/
    font-size: 11px;
    font-weight: normal;
    /*line-height: 55px;*/
    line-height: 10px;
  }

  .words {
    display: block;
    position: absolute;
    left: 5px;
    top: 45px;
    width: calc(100% - 10px);
    /*border-left:7px solid #fff;*/
    /*border-right:7px solid #fff;*/
    overflow-x: hidden;
    height: 150px;
    background: #fff;
    text-align: left;
    line-height: normal;
    border-radius: 5px;
    box-shadow: 1px 1px 2px #e9e9e9;
    overflow-y: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word
  }
  .others {
    position: absolute;
    top: 200px;
    left: 10px;
    width: calc(100% - 20px);
    height: 50px;
  }
  .icons {
    position: absolute;
    top: 0;
    left: 0;
  }

  .saw {
    position: absolute;
    top: 25px;
    left: 0;
    font-size: 12px;
  }

  .org {
    cursor: pointer;
    position: absolute;
    top: 20px;
    left: calc(100% - 100px);
    width: 80px;
    height: 20px;
    font-size: 12px;
    line-height: 20px;
    background: #fff;
    box-shadow: 0 0 1px #e9e9e9;
    border-radius: 5px
  }
  @media (min-width: 768px) {

    .commentcover {
      display: none;
    }
    .org{
      display: none;
      box-shadow: 0 0 4px #cbcbcb;
    }
    .sendcomment {
      display: none;
    }
    .author{
      display: none;
    }
    .title{
      width: auto;
      left:20px;
      top:10px;
      box-shadow: none;
    }
    .words{
      box-shadow: none;
      width:calc(100% - 80px);
      left:60px;
    }
  }
  @media (max-width: 768px) {
    .author {
      top: 50px;
      right: 75px;
    }
    .date {
      top: 50px;
    }
    .words {
      top: 70px;
    }
    .others {
      top: 230px;
    }
    .saw {
      top: 20px;
      left: 0;
    }
    .org {
      top: 0px;
      height: 35px;
      font-size: 12px;
      left: calc(100% - 75px);
      line-height: 35px;
    }
    .commentcover {
      display: block;
      position: absolute;
      top: 40px;
      left: 0px;
      border-radius: 5px;
      border: 1px solid #eee;
      width: calc(100% - 100px);
      height: 30px;
    }

    .sendcomment {
      cursor: pointer;
      position: absolute;
      top: 40px;
      left: calc(100% - 75px);
      width: 80px;
      line-height: 35px;
      height: 35px;
      font-size: 12px;
      background: #fff;
      box-shadow: 0 0 1px #e9e9e9;
      border-radius: 5px
    }
  }
</style>
